/* Global styles and reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
}

/* Main container - adapts to iframe or standalone */
#main-container {
    width: 100%;
    height: 450px;
    position: relative;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Standalone mode - uses 90vh */
body:not(.iframe-mode) #main-container {
    height: 90vh;
    min-height: 600px;
}

/* Tooltip - center positioned for iframe viewing */
.tooltip {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1000;
    max-width: 80%;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.tooltip.show {
    opacity: 1;
}

/* Story panel - narrative context */
.story-panel {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    text-align: center;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.5s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Timer container with visual countdown */
.timer-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.95);
    gap: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.timer-label {
    font-weight: bold;
    color: #333;
    font-size: 14px;
}

.timer {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
    min-width: 50px;
    text-align: center;
}

.timer.warning {
    color: #ff6b6b;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.timer-bar {
    flex: 1;
    max-width: 200px;
    height: 10px;
    background: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
}

.timer-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s linear;
}

/* Score panel */
.score-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.score-label, .progress-label {
    color: #666;
}

#score, #progress {
    color: #667eea;
    font-size: 16px;
}

/* Game area - main interactive zone */
.game-area {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 250px;
}

/* Categories container */
.categories-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

/* Category zones - drop targets */
.category-zone {
    background: rgba(255, 255, 255, 0.95);
    border: 3px dashed #ccc;
    border-radius: 12px;
    padding: 8px;
    min-height: 120px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.category-zone:hover {
    border-color: #667eea;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transform: translateY(-2px);
}

.category-zone.drag-over {
    background: rgba(102, 126, 234, 0.1);
    border-color: #667eea;
    border-style: solid;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.4);
}

.category-header {
    font-weight: bold;
    color: #667eea;
    text-align: center;
    margin-bottom: 8px;
    font-size: 13px;
    padding: 5px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 6px;
}

.category-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Tips pool - source of draggable items */
.tips-pool {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.pool-header {
    font-weight: bold;
    color: #764ba2;
    text-align: center;
    margin-bottom: 10px;
    font-size: 14px;
    padding: 5px;
    background: rgba(118, 75, 162, 0.1);
    border-radius: 6px;
}

.tips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

/* Draggable tip items */
.tip-item {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: grab;
    user-select: none;
    font-size: 12px;
    line-height: 1.3;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: 180px;
}

.tip-item:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.tip-item:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.tip-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.tip-item.correct {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    animation: correctPulse 0.5s ease;
}

.tip-item.incorrect {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    animation: shake 0.5s ease;
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Controls section */
.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px 20px;
}

/* Button styles */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    min-height: 40px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn-start {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.btn-reset {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
}

.btn-sound {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    padding: 10px 15px;
    font-size: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Modal for results */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

#result-title {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 24px;
}

#result-message {
    font-size: 16px;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.6;
}

#result-details {
    background: #f5f7fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #666;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .categories-container {
        grid-template-columns: 1fr;
    }
    
    .tip-item {
        max-width: 100%;
    }
    
    .timer-bar {
        max-width: 150px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .tip-item {
        min-height: 44px;
        padding: 10px 15px;
    }
    
    .btn {
        min-height: 44px;
        padding: 12px 24px;
    }
    
    .category-zone {
        min-height: 150px;
    }
}